<script type="text/javascript" src="http://{$strona.domena}/P/js/flexigrid/flexigrid.pack.js"></script>
<link rel="stylesheet" type="text/css" href="http://{$strona.domena}/P/style/flexigrid/flexigrid.pack.css" />

<div class="zawartosc">
    <table id="lista" cellspacing="0"></table>
</div>

<script type="text/javascript">
{literal}
$(function() {
    $("#lista").flexigrid({
            url: '/cms/artykul/akcja,xml.html',
            dataType: 'json',
            colModel : [
                    {display: 'ID', name : 'id', width : 40, sortable : true, align: 'left'},
                    {display: 'Login dodającego', name : 'login', width : 120, sortable : true, align: 'center'},
                    {display: 'Url', name : 'url', width : 150, sortable : true, align: 'center'},
                    {display: 'Tytuł', name : 'tytul', width : 200, sortable : true, align: 'center'},
                    {display: 'Zajawka', name : 'zajawka', width : 200, align: 'center'},
                    {display: 'Data dodania', name : 'datadodania', width : 120, sortable : true, align: 'center'},
                    {display: 'Komentarzy', name : 'komentarze', width : 90, sortable : true, align: 'center'},
                    {display: 'Tagi', name : 'tagi', width : 180, align: 'center'},
                    {display: 'Status', name : 'status', width : 50, sortable : true, align: 'center'}
            ],
            buttons : [
                    {name: 'Edit', bclass: 'edit', onpress : doCommand},
                    {name: 'Delete', bclass: 'delete', onpress : doCommand},
                    {separator: true}
            ],
            searchitems : [
                    {display: 'Login dodającego', name : 'login', isdefault: true}
            ],
            sortname: "id",
            sortorder: "asc",
            usepager: true,
            useRp: true,
            rp: 10,
            showTableToggleBtn: false,
            resizable: false,
            height: 500
    });
});

function doCommand(com, grid) {
    if (com == 'Edit') {
        $('.trSelected', grid).each(function() {
            var id = $(this).attr('id');
            id = id.substring(id.lastIndexOf('row')+3);
            alert("Edit row " + id);
        });
    } else if (com == 'Delete') {
        $('.trSelected', grid).each(function() {
            var id = $(this).attr('id');
            id = id.substring(id.lastIndexOf('row')+3);
            alert("Delete row " + id);
        });
    }
}
{/literal}
</script>
